﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using coliseu.BussinessLayer;

namespace coliseu.Views.Condominio
{
    public partial class FrmListCargo : Form
    {
        private CargoBL cl = new CargoBL();

        public FrmListCargo()
        {
            InitializeComponent();
        }

        private void FrmListCargo_Load(object sender, EventArgs e)
        {
            cargoBindingSource.DataSource = cl.selecionar();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            FrmCadCargo c = new FrmCadCargo(cl);
            c.ShowDialog();
            cargoBindingSource.DataSource = cl.selecionar();
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            FrmCadCargo c = new FrmCadCargo(cl, ((cargo)cargoBindingSource.Current));
            c.ShowDialog();
            cargoBindingSource.DataSource = cl.selecionar();
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Deseja excluir?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                cl.excluir((cargo)cargoBindingSource.Current);
                cargoBindingSource.DataSource = cl.selecionar();
            }
        }

        private void dtGrdVwBloco_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1)
                toolStripButton2_Click(null, new EventArgs());
        }
    }
}
